package main

import "fmt"

type Sender interface {
	Send(to, msg string) error
	SendAll(tos []string, msg string) error
}

type WeChatSender struct {
	sessionFile string
}

func NewWeChatSender(sessionFile string) *WeChatSender {
	return &WeChatSender{sessionFile}
}

//接收者为值对象
func (sender WeChatSender) Send(to, msg string) error {
	fmt.Printf("发送微信给: %s,内容: %s\n", to, msg)
	return nil
}

//接收者为指针对象
func (sender *WeChatSender) SendAll(tos []string, msg string) error {
	for _, to := range tos {
		fmt.Printf("发送微信给: %s,内容: %s\n", to, msg)
	}
	return nil
}

func main() {
	//var sender03 Sender
	sender03 := &WeChatSender{"/tmp/wx.session"}
	fmt.Printf("%T: %v\n", sender03, sender03)
	sender03.Send("13661461543", "hi lwq")
	sender03.SendAll([]string{"13661461543", "1364888265"}, "good")
}
